#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <deque>

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class QTimer;
class QKeyEvent;
class QPaintEvent;
class MainWindow : public QMainWindow
{
    Q_OBJECT

    enum class TileType {
        EMPTY, BODY, WALL
    };
    enum class SnakeDirection {
        UP, DOWN, LEFT, RIGHT
    };


    const static int MAP_SIZE = 20;
    QTimer* timer;
    std::deque<std::pair<int, int> > snakeBody;
    std::pair<int, int> foodPos;
    SnakeDirection direction;
    TileType map[MAP_SIZE][MAP_SIZE];


public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

    void paintEvent(QPaintEvent* event);
    void keyPressEvent(QKeyEvent* event);
    void paintSnake();
    void processSnake();
    void generateFood();
    void paintAt(int, int, Qt::GlobalColor, QPainter&);
    bool moveSnakeTo(int, int);
private:
    Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
